package org.itheima.game.org.tank.game.model

import org.itheima.game.org.tank.game.Config
import org.itheima.game.org.tank.game.business.Destroyable
import org.itheima.kotlin.game.core.Painter


/**
 * description ： 爆炸物
 * author : chenmengjia
 * email : cmjsp1990@163.com
 * date : 2020/3/15 09:55
 */
class Blast(override var x: Int, override var y: Int) : View, Destroyable {
    override fun isDestroyed(): Boolean {
        return index>=imagePaths.size
    }

    override var width: Int = Config.block
    override var height: Int = Config.block
    private val imagePaths = arrayListOf<String>()
    private var index = 0

    init {
        (1..32).forEach {
            imagePaths.add("img/blast_${it}.png")
        }
    }


    override fun draw() {
        val i=index%imagePaths.size
        Painter.drawImage(imagePaths[i],x,y)
        index++

    }

}